$(function(){
    // 渲染分类
    $.ajax({
        url: "http://127.0.0.1:9090/api/getcategorytitle",
        dataType: "json",
        success: function(result){
            console.log(result);
            $(".list-con").html(template("temp",result));
        }
    });

    $(".list-con").on("click",".box",function(){
        var id = $(this).data("id");
        var that = this;
        // console.log($(this).data("id"));
        $.ajax({
            url: "http://127.0.0.1:9090/api/getcategory",
            data: {titleid: id},
            dataType: "json",
            success: function(result){
                $(that).siblings(".cate-list").html(template("temp2",result));
                $(that).siblings(".cate-list").toggleClass("show");
            }
        });
    });

    $(".list-con").on("click","a",function(e){
        var id = $(this).data("id");
        location.href = "cateSecond.html?id=" + id;
    });
});